package com.maimao.utils.excel.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * Excel导出 订单状态转换器
 *
 * @author MaoLin Wang
 * @date 2021/6/7 上午11:37
 */
public class OrderStatusConvert implements Converter<Integer> {
    private static final Integer ONE = 1;
    private static final Integer TWO = 2;

    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        switch (value) {
            case 1:
                return new CellData("待付款");
            case 2:
                return new CellData("待发货");
            case 5:
                return new CellData("交易成功");
            case 6:
                return new CellData("交易取消");
            default:
                return new CellData("---");
        }
    }
}
